❓Как влияет порядок defer-вызовов на поведение программы
Конструкция defer в Go вызывает функции в обратном порядке, по принципу стека (LIFO — Last In, First Out). То есть последняя отложенная функция будет выполнена первой при выходе из текущей функции.
Сначала закроется b.txt, потом a.txt — что логично.
•Откат операций в нужной последовательности: При выполнении нескольких шагов (например, в транзакции), можно отложить откат в порядке, обратном их применению.
•Отладка и читаемость: Если defer-вызовов много, особенно внутри циклов и функций, легко запутаться в порядке их выполнения. Это стоит учитывать при разработке.
❓Как влияет порядок defer-вызовов на поведение программы
Конструкция defer в Go вызывает функции в обратном порядке, по принципу стека (LIFO — Last In, First Out). То есть последняя отложенная функция будет выполнена первой при выходе из текущей функции.
Сначала закроется b.txt, потом a.txt — что логично.
•Откат операций в нужной последовательности: При выполнении нескольких шагов (например, в транзакции), можно отложить откат в порядке, обратном их применению.
•Отладка и читаемость: Если defer-вызовов много, особенно внутри циклов и функций, легко запутаться в порядке их выполнения. Это стоит учитывать при разработке.
Some messages aren’t supposed to last forever. There are some Telegram groups and conversations where it’s best if messages are automatically deleted in a day or a week. Here’s how to auto-delete messages in any Telegram chat. You can enable the auto-delete feature on a per-chat basis. It works for both one-on-one conversations and group chats. Previously, you needed to use the Secret Chat feature to automatically delete messages after a set time. At the time of writing, you can choose to automatically delete messages after a day or a week. Telegram starts the timer once they are sent, not after they are read. This won’t affect the messages that were sent before enabling the feature.
Telegram hopes to raise $1bn with a convertible bond private placement
The super secure UAE-based Telegram messenger service, developed by Russian-born software icon Pavel Durov, is looking to raise $1bn through a bond placement to a limited number of investors from Russia, Europe, Asia and the Middle East, the Kommersant daily reported citing unnamed sources on February 18, 2021.The issue reportedly comprises exchange bonds that could be converted into equity in the messaging service that is currently 100% owned by Durov and his brother Nikolai.Kommersant reports that the price of the conversion would be at a 10% discount to a potential IPO should it happen within five years.The minimum bond placement is said to be set at $50mn, but could be lowered to $10mn. Five-year bonds could carry an annual coupon of 7-8%.
Библиотека Go для собеса | вопросы с собеседований from ua